const news=[{
    id:'1',
    title:"这是一虚拟的题目",
    poster:"cloud://cloud1-9gm3f7qf78e7cc26.636c-cloud1-9gm3f7qf78e7cc26-1310604282/images/xiaoyuan2.jpeg",
    content:"这里是详细内容                           - --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------",
    add_date:'2022-04-18'
},{
    id:"2",
    title:"这是另一条虚拟题目",
    poster:"cloud://cloud1-9gm3f7qf78e7cc26.636c-cloud1-9gm3f7qf78e7cc26-1310604282/images/xiaoyuan1.jpeg",
    content:"这里是第二的详细内容==========================================================================================================================================================================================================",
    add_date:'2022-4-19'
},{
    id:'3',
    title:'这依旧是一条虚拟的题目',
    poster:'cloud://cloud1-9gm3f7qf78e7cc26.636c-cloud1-9gm3f7qf78e7cc26-1310604282/images/xiaoyuan.jpeg',
    content:'这里是第三题的详细内容+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++',
    add_date:'2022-4-20'
}
];



// 获取新闻列表
function getNewsList(){
    let list=[];
    for(var i=0;i<news.length;i++){
        let obj={};
        obj.id=news[i].id;
        obj.poster=news[i].poster;
        obj.add_date=news[i].add_date;
        obj.title=news[i].title;
        list.push(obj);
    }
    return list;
}


function getNewsDetail(newsID){
    let msg={
        code:'404',
        news:{}
    };
    for(var i=0;i<news.length;i++){

        if(newsID==news[i].id){
            msg.code='200';
            msg.news=news[i];
            break;
        }
    }
    return msg;
}




module.exports={
    getNewsList:getNewsList,
    getNewsDetail:getNewsDetail
}